
import {
	defineStore
} from 'pinia'

import {
	ref
} from 'vue'
export const userStore = defineStore("user", () => {
	let token=ref("")
	let userInfo = ref({})
	let isLogin = ref(false)
	let currentPos=ref({
		// latitude:0,
		// longitude:0
		latitude:34.342,
		longitude:108.9397
	})
	 
	 let hasPos=ref(false)
	
	function addUserInfo(objectId, username, phone) {	
		this.userInfo.objectId=objectId
		this.userInfo.username=username
		this.userInfo.phone=phone
		// this.userInfo.token=token
		this.isLogin=true
   //自行添加内容
	}
	// 清除用户登录状态
	function clearUserInfo() { 
		this.userInfo = {}
		this.isLogin = false
		this.token = ""
//自行添加内容
	}
	function setPos(lat,lon)
	{
		currentPos.value.latitude=lat,
		currentPos.value.longitude=lon
		hasPos.value=true
	}
 
	return {
		
		userInfo,
		isLogin, 
		addUserInfo,
		clearUserInfo,
		currentPos,
		hasPos,
		setPos
	}
})